home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 4671-5.790 / dmg-5373 / dck / control1.doc < prev    next >
Text File  |  1995-10-25  |  14KB  |  408 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. Welcome to the first proper Control EXTENTION tutorial in SteStosTerone.
  9.  
  10.  
  11.  
  12.  
  13. I know I teased you all in issue 2, but it is important that you 
  14. register Control. This Extention is the only way at present to
  15. combine sprites and hardware  scrolling.
  16.  
  17.  
  18. So, I will assume that you have the registered version !!!!!
  19.  
  20.  
  21.  
  22. First, a treat !
  23.  
  24. On this disk you will find a folder called INVADERS.
  25.            This folder contains a small invaders game written 
  26.            by   Mr Greenhalgh. LJ was kind enough to supply 
  27.            the full source and graphics for you to examine.
  28.            It doesn't need any other extention ( but Control...)
  29.      
  30.  
  31.  
  32.  
  33. All the .bas  files are compressed using STZIP.PRG which you will find 
  34. on this disk.
  35. Read the STZip documentation, and then extract all the files to some blank 
  36. disk, or your hard disk.
  37.        
  38. (You do need Issue 1 and 2 of SteStosTerone , if you can't understand
  39. why this tutorial is here, and why it is important to register the 
  40. Control extention.)
  41.  
  42.  
  43.  
  44. ***********************************************************************
  45.  
  46.    How to create sprites to use with control.
  47.    and what to do with them ?
  48.    
  49.    
  50. ***********************************************************************
  51. The support files can be found in the folder \CONTROL1
  52.  
  53.  
  54.  
  55.  
  56.  
  57. First create some sprites, as usual with the STOS SPRITE Editor
  58. and call the file BALLCUPS.MBK   
  59. (make them 64*64 pixels in size) 
  60. For the purpose of this tutorial, I suggest you draw a Ball and
  61. a Cup big enough to catch it when it drops from the top of the
  62. screen. That is why I called the sprite bank BALLCUPS.MBK. 
  63. The <S> stands for -STOS-        <MBK> is the sprite banks name extention
  64.  
  65. For those who want, there is a ready made file in the folder for you to
  66. examine and edit.
  67.  
  68. Next load the MAKE.BAS from the Control Extention . I hope you registered!
  69. Otherwise try the PD version that was in issue 1 of SteS.......
  70.  
  71.  
  72. I hope that following my advice from previous issues , you have printed 
  73. out the manuals, and the tutorials such as the Doc for Maker.bas, and even 
  74. this file!.       If not, then please do!
  75.  
  76.  
  77. Once on the main menu of MAKER.BAS, select 16 images and size 64 for both 
  78. values of X and Y
  79.  
  80. Click on the long < make sprite bank> icon and follow the sreen prompts.
  81. Load BALLCUPS.MBK as Stos sprite bank to be converted, and Save the 
  82. resulting file  as BALLCUPC.MBK
  83. note : I changed the letter S for C(ontrol)
  84.  
  85. Again, I also have a ready made file for you, in the folder ! 
  86.  
  87.  
  88.  
  89.    
  90. *******************************************************************
  91.  
  92.                   Animating sprites Using control
  93.                                                                                                                                 
  94. ********************************************************************
  95.  
  96.  
  97. In the folder you will find : bas1.bas
  98.                 bas2.bas
  99.                  bas3.bas
  100.                      ....
  101. .... so you can just load them up and experiment.
  102.  
  103.  
  104.  
  105. But here is  the line by line analysis:
  106.  
  107. BAS1.BAS:    Loads and animates a sprite that can be 
  108.              mouved with the mouse   
  109.  
  110.  
  111.  
  112. 10 rem ******* (C)1995 JJH *******
  113. 20 rem         SPRITES USING
  114. 30 rem          CONTROL EXT.
  115. 40 rem ******* (C)1995 JJH *******
  116. 50 mode 0 : flash off : key off : hide : fade 1             /set up
  117.  
  118. 60 reserve as screen 10 : IMG=2
  119. 70 load "ballcupc.mbk",1                                    /load image 
  120.                             bank of sprites we 
  121.                             created with the 
  122.                             make program 
  123.                             supplied with 
  124.                             Control
  125.                             
  126.                             
  127. 80 load "ballcup.neo",10                                 / load backgroud 
  128.                                                            image
  129. 90 logic=back
  130. 100 turbocopy start(10),physic                           / copy it to 
  131.                                                            physic
  132. 110 get palette (10)
  133. 120 rem ******* (C)1995 JJH *******
  134. 130 screen size 320,200                                  / Tell the new
  135.                                                            sprite engine 
  136.                                                            what the size 
  137.                                                            of the virtual 
  138.                                                            screen is.
  139.                                                            
  140. 140 set clip 1,1,319,199                                 / clipping 
  141.                                                          coordinates
  142.                                                          for sprites
  143.                                                          
  144. 150 turbocopy start(10),logic                            / Fast Control 
  145.                                            command that copies 32k screen.
  146.                                            Here, it is used to update the 
  147.                                            entire Logical screen, before a 
  148.                                            new sprite is displayed.
  149.                                            
  150. 160 inc IMG : if IMG>5 then IMG=2          / The sprite images 2,3,4and 5
  151.                                              are the animation frames.
  152.                                              This system loops the 
  153.                                              animation.
  154.                                              
  155. 170 X=x mouse : Y=y mouse                  /Get mouse coordinates
  156.  
  157. 180 image put logic,X,Y,start(1),IMG,1     / New command displaying
  158.                                              the Control sprites.
  159.                                              Logic,    is the destination
  160.                                              x,y,      are the coordinates
  161.                                              Start(1), is the address of 
  162.                                                        the sprite bank
  163.                                              IMG,      is the frame to 
  164.                                                        display 
  165.                                              1         Transparent mode
  166.                                                        (0 would be solid)          
  167.                                                       
  168.                                              
  169. 190 screen swap : wait vbl                   /    As usual
  170.  
  171. 200 if fire then wait 10 : default : end     / exit if mouse click
  172.  
  173. 210 goto 150
  174.                      
  175.  
  176. *********  New Commands  : 
  177.  
  178.  
  179.              SCREEN SIZE x,y
  180.                                      use 320,200 unless
  181.                                      using hardware scrolling.
  182.                                      
  183.              TURBOCOPY Sourceaddress, Destaddress
  184.                                      Copies 32K of screen data
  185.                                      from source address to destination
  186.                                             
  187.              IMAGE PUT destadd,dx,dy,Souradd,Frame, mode 
  188.                                      Displays a sprite on the screen
  189.                                      destadd, at coordinates dx,dy.
  190.                                      Souradd is the sprite banks address 
  191.                                      and usually Start(1)
  192.                                      Frame is the sprite image to be 
  193.                                      displayed 
  194.                                      Mode can be 0 or 1. Mostly use
  195.                                      1 if the sprites must be transparent 
  196.                                      and merged onto the background. 0 is 
  197.                                      faster.
  198.                                      
  199.  
  200. ********************
  201.  
  202. BAS2.BAS
  203. ********************
  204.  
  205. Same as above , but combining the sprite with hardware scrolling.
  206.  
  207.  
  208. 100 rem ******* (C)1995 JJH *******
  209. 200 rem         SPRITES USING
  210. 300 rem          CONTROL EXT.
  211. 400 rem ******* (C)1995 JJH *******
  212. 500 mode 0 : flash off : key off : hide : fade 1
  213. 600 reserve as screen 10 : IMG=2
  214. 700 reserve as work 11,64000
  215. 800 load "ballcupc.mbk",1
  216. 900 load "ballcup.neo",10
  217.  
  218.  
  219. 1000 copy start(10),start(10)+32000 to start(11)
  220. 1100 copy start(10),start(10)+32000 to start(11)+32000
  221.                                            /We build a screen bank
  222.                                            320*400 in size
  223.                                             
  224. 1200 bcopy 11 to 12
  225. 1300 bcopy 11 to 13
  226.                      / We make two copies of this Virtual screen bank
  227.                      
  228. 1400 logic=back
  229.  
  230. 1500 turbocopy start(10),physic
  231. 1600 get palette (10)
  232. 1700 rem ******* (C)1995 JJH *******
  233. 1800 screen size 320,400 : hard screen size 320,400,0
  234.                 /We tell the Control extention  and
  235.                 the STE extention the virtual screen size
  236.                 
  237.  
  238. 1900 set clip 1,1,320,400         /  Control's clipping zone
  239.  
  240. 1905 Q=hard physic(start(13)) : hard inter on : y mouse=0
  241.                   /  Tell the STE extention where
  242.                   our Virtual Physical screen is
  243.                   and starts the hardware interupt.
  244.                   We also place the mouse at the top of
  245.                   the screen
  246.                   
  247. 2000 LO1=start(11) : LO2=start(12) : PHY=start(13)
  248.                     / Give names to virtual screen 
  249.                     banks
  250.                     LO1  is logical
  251.                     LO2 holds a  backround copy
  252.                     PHY is used as physical
  253.                     
  254. 2100 inc IMG : if IMG>5 then IMG=2       / sprite animation frame
  255.                                            calculated
  256.                                            
  257.  
  258. 2200 X=x mouse : Y=y mouse*4             / mouse coordinates
  259.  
  260. 2201 if Y>400 then Y=400                 / Limit mouse mouvement
  261.  
  262.  
  263. 2300 image put LO1,X,Y,start(1),IMG,1   /  Display sprite
  264.  
  265. 2450 YY=Y/2 : if YY>200 then Y=200
  266. 2451 if YY>200 then Y=200               / Calculate the y Offset value
  267.                                         for the STE extention. Refer to 
  268.                                         issue 2 of SteStosTerone for 
  269.                                         details
  270.                                         
  271.                                            
  272. 2500 if fire then wait 10 : default : hard inter off : end 
  273.  
  274. 2550 hard screen offset 0,YY              / tell STE extention which part 
  275.                                             of  the virtual screen to 
  276.                                             start showing from
  277.                                             
  278.  
  279. 2555 Q=hard physic(PHY)                  /  Tell STE extention where the 
  280.                                      virtual screenbank is 
  281.  
  282.  
  283. 2560 wait vbl : swap PHY,LO1             / Swap our logical and physical 
  284.                                            Pseudo screen addresses.
  285.  
  286. 2600 goto 2100
  287.                                      
  288. *******
  289. When yo run this program, you will notice
  290. that we now have a hardware scolling 
  291. background , but that the sprite's background is 
  292. not updated automaticaly. Rather than updating the 
  293. full screen as in the first example , we will 
  294. only update the area of the sprite, saving a lot of
  295. time.   
  296.  
  297.    This is what happens in :
  298.  
  299. *************
  300. BAS3.BAS
  301. *************
  302. 10 rem ******* (C)1995 JJH *******
  303. 20 rem         SPRITES USING
  304. 30 rem          CONTROL EXT.
  305. 40 rem ******* (C)1995 JJH *******
  306. 45 rem*
  307. 50 rem*       mouse controled
  308. 54 rem*
  309. 60 rem ******* (C)1995 JJH *******
  310. 70 mode 0 : flash off : key off : hide : fade 1
  311. 80 reserve as screen 10 : IMG=2
  312. 90 reserve as work 11,64000
  313. 100 load "ballcupc.mbk",1
  314. 110 load "ballcup.neo",10
  315. 120 copy start(10),start(10)+32000 to start(11)
  316. 130 copy start(10),start(10)+32000 to start(11)+32000
  317. 140 bcopy 11 to 12
  318. 150 bcopy 11 to 13
  319. 160 logic=back
  320. 170 turbocopy start(10),physic
  321. 180 get palette (10)
  322. 190 rem ******* (C)1995 JJH *******
  323. 200 screen size 320,400 : hard screen size 320,400,0
  324. 210 set clip 0,0,320,400
  325. 220 Q=hard physic(start(13)) : hard inter on : y mouse=0
  326. 230 LO1=start(11) : LO2=start(12) : PHY=start(13)
  327.  
  328. 240 inc IMG : if IMG>10 then IMG=4        / I changed this to slow down
  329.                                             the animations frame rate
  330.                                             (  check line 290  )
  331.                                             
  332. 250 OLDX=X : OLDY=Y                        / I save the old
  333.                                              sprite coordinates,
  334.                                              as that is the area that will 
  335.                                              need restoring
  336.                                              
  337. 260 X=x mouse : Y=y mouse*4
  338. 270 if Y>360 then Y=360
  339. 280 if Y<64 then Y=64
  340.  
  341. 290 IM=IMG/2 : image put LO1,X,Y,start(1),IM,1
  342.                                    / Display the new sprite
  343.                                    
  344. 300 YY=Y/2 : if YY>200 then Y=200
  345. 310 if YY>200 then Y=200
  346. 320 if fire then wait 10 : default : hard inter off : end 
  347. 330 hard screen offset 0,YY
  348. 340 Q=hard physic(LO1)
  349. 350 wait vbl : swap PHY,LO1
  350.  
  351. 360 bigcopy LO2,OLDX,OLDY,OLDX+48,OLDY+32,LO1,OLDX,OLDY
  352.                                   / Erase the old Sprite
  353.                                   We use LO2 as source,
  354.                                   and copy onto LO1
  355.                                                       
  356. 370 goto 240
  357.  
  358. *****   NEW COMMAND
  359.  
  360. BIG COPY   source add, x1,y1,x2,y2,destination add,x,y
  361.  
  362.             Source add,      /Our Background address
  363.             X1,Y1            /Coordinates of top left corner
  364.             X2,Y2            /          ..   bottom right ..
  365.             Destination add  /Logical screen address as 
  366.                               destination
  367.             X,Y               /Top left corner coordinates of 
  368.                               destination 
  369.                               
  370.                                     
  371.  
  372. Seriously, load the source code in STOS. Experiment, and 
  373. build on the examples. These 3 programs are designed to let you 
  374. get familiar with the principals. 
  375. Once you feel more confident , build a 640*200 screen
  376. and use horizontal hardware scrolling.
  377. Be sure to set the screen sizes and clipping areaes.                                    
  378.                                      
  379.                                        
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.             
  390.             
  391.             
  392.             
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.             
  403.             
  404.             
  405.             
  406.         
  407.         
  408.